<style type="text/css">
	a.btnDelete img{display:none;}
</style>
<script type="text/javascript">
//<![CDATA[        
	function frmValid(){
		with(document.frmReg){
			var tel = getInputHashmap($('[name="tel[]"]'));
			var hp = getInputHashmap($('[name="hp[]"]'));
					
			if(checkEmpty(name)){
				alert('성함을 입력 하세요.');
				return;
			}
			
			var email = mail_id.value+'@'+mail_domain.value;
			if(!checkEmail(email)){
				alert('이메일주소를 정확히 입력해주세요');
				return;
			}
				
			if(tel.length > 0){
				if(!telRegEx.test(tel.join("-"))){
					alert("전화번호를 정확히 입력해주세요");
					return;
				}
			}

			if(hp.length > 0){
				if(!hpRegEx.test(tel.join("-"))){
					alert("핸드폰 번호를 정확히 입력해주세요");
					return;
				}
			}	

			submit();
		}
	}

	function frmDelete(){
		if(!confirm('삭제 하시겠습니까?'))return;
		with(document.frmReg){
			dbjob.value = 'd';
			submit();
		}	 
	}

	$(function(){
		//삭제버튼
		if($("[name=dbjob]").val() == 'u'){ 
			$("a.btnDelete img").show();
		}
		
		//이메일
		$("[name=domain_support]").change(function(){
			if($(this).val()){
				$("[name=mail_domain]").attr("readonly",true);
				$("[name=mail_domain]").val($(this).val());
			}else{
				$("[name=mail_domain]").attr("readonly",false);
				$("[name=mail_domain]").val('');
				$("[name=mail_domain]").focus();
			}
		});
	
	});
//]]>
</script>
<div class="box_type02">
	<h2 class="txt">교역자관리</h2>
	<p class="icon"><a href="javascript:void(0);" class="icon_m04">매뉴얼</a></p>
	<!--[s] 쓰기 -->
	<form name="frmReg" method="post" action="/worker/workerDbjob" enctype="multipart/form-data">
	<?php 
		$hidden = array('dbjob'=>$dbjob,'id'=>$id);
		echo form_hidden($hidden);
	?>
	<fieldset class="board_write">
		<legend>설교방송관리</legend>
		<table cellspacing="0" summary="설교방송관리" class="lines">
			<caption>설교방송관리</caption>
			<tr>
				<th scope="row" width="140"><p class="point">직책</p></th>
				<td>
					<div>
						<select name="duty" class="ip_s" style="width:180px;">
							<?php 
								foreach($code_duty as $row){
									$selected = ($row->code_id == $duty) ? 'selected' : '';
									echo "<option value=\"{$row->code_id}\" {$selected}>{$row->title}</option>\n";
								}
							?>
						</select>
						<span class="txt_type02">추가시 코드관리에서 등록</span>
					</div>
				</td>
			</tr>
			<tr>
				<th scope="row"><p class="point">직함</p></th>
				<td>
					<div>
						<select name="title" class="ip_s" style="width:180px;">
							<?php 
								foreach($code_title as $row){
									$selected = ($row->code_id == $duty) ? 'selected' : '';
									echo "<option value=\"{$row->code_id}\" {$selected}>{$row->title}</option>\n";
								}
							?>
						</select>
					</div>
				</td>
			</tr>
			<tr>
				<th scope="row"><p class="point">성함</p></th>
				<td>
					<div>
						<input type="text" id="" name="name" class="ip_i" style="width:158px;" value="<?php echo $name;?>" />
					</div>
				</td>
			</tr>
			<tr>
				<th scope="row"><p class="point">이미지</p></th>
				<td>
					<div>
						<input type="file" id="" name="files[]" class="ip_i" style="width:279px;" value="" />
						<?php 
							if($photo){
								$photo_file = explode('|',$photo);
								echo '<div><span class="txt_type01"><strong>이미지 :</strong>'.$photo_file[1].'</div>';
							}
						?>
						<span class="txt_type02">.180x121</span>
					</div>
				</td>
			</tr>
			<tr>
				<th scope="row"><p class="point">이메일</p></th>
				<td>
					<div>
						<input type="text" id="" name="mail_id" class="ip_i" style="width:155px;" value="<?php echo $mail_id;?>" />
						<span class="txt_type01">@</span>
						<input type="text" id="" name="mail_domain" class="ip_i" style="width:155px;" value="<?php echo $mail_domain;?>" />
						<select name="domain_support" class="ip_s ml6" style="width:130px;">
							<option value="">직접입력</option>
							<?php 
								foreach($this->config->item('ch_mail_domain') as $key){
									$selected = ($key == $mail_domain) ? 'selected' :'';
									echo "<option value=\"{$key}\" {$selected}>{$key}</option>\n";
								}
							?>
						</select>
					</div>
				</td>
			</tr>
			<tr>
				<th scope="row"><p class="point">전화번호</p></th>
				<td>
					<div>
						<input type="text" id="" name="tel[]" maxlength="3" class="ip_i" style="width:23px;" value="<?php echo $tel1;?>" />
						<span class="txt_type01">-</span>
						<input type="text" id="" name="tel[]" maxlength="4" class="ip_i" style="width:43px;" value="<?php echo $tel2;?>" />
						<span class="txt_type01">-</span>
						<input type="text" id="" name="tel[]" maxlength="4" class="ip_i" style="width:43px;" value="<?php echo $tel3;?>" />
					</div>
				</td>
			</tr>
			<tr>
				<th scope="row"><p class="point">휴대폰</p></th>
				<td>
					<div>
						<input type="text" id="" name="hp[]" maxlength="3" class="ip_i" style="width:23px;" value="<?php echo $hp1;?>" />
						<span class="txt_type01">-</span>
						<input type="text" id="" name="hp[]" maxlength="4" class="ip_i" style="width:43px;" value="<?php echo $hp2;?>" />
						<span class="txt_type01">-</span>
						<input type="text" id="" name="hp[]" maxlength="4" class="ip_i" style="width:43px;" value="<?php echo $hp3;?>" />
					</div>
				</td>
			</tr>
		</table>
	</fieldset>
	</form>
	<!--[e] 쓰기 -->
	<!-- [s] 버튼 -->
	<ul class="botton_box mt30">
		<li class="center">
			<?php 
				//버튼 이미지 변경
				$btn_image = ($dbjob == 'i') ? 'btn_ok.gif' : 'btn_modify.gif';
			?>
			<a href="javascript:frmValid();"><img src="/theme/<?=$_theme?>/images/common/<?php echo $btn_image;?>" alt="" /></a>
			<a href="javascript:frmDelete();" class="btnDelete"><img src="/theme/<?=$_theme?>/images/common/btn_delete.gif" alt="삭제" /></a>
			<a href="javascript:history.back();"><img src="/theme/<?=$_theme?>/images/common/btn_cancel.gif" alt="취소" /></a>
		</li>
	</ul>
	<!-- [e] 버튼 -->
	<!--[s] Tip -->
	<dl id="tip" style="border-top:0;"><!--  class="mt30" -->
		<dt>Tip</dt>
		<dd>인터넷익스플로러의 '호환성보기' 기능을 사용중인 접속자에게 자동으로 최신버전 기준으로 사이트를 출력하도록 처리합니다.</dd>
		<dd>코딩방식에 따라 특정 버전의 브라우저에서 사이트가 깨질수 있으니, 충분한 테스트 후 기능을 설정해 주시기 바랍니다.</dd>
	</dl>
	<!--[e] Tip -->
</div>